package com.woniu40.petai_user.web;

import com.woniu40.petai_user.entity.Dynamic;

import com.woniu40.petai_user.entity.User;
import com.woniu40.petai_user.service.ReportService;
import com.woniu40.petai_user.vo.ReportVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.Date;
import java.util.Map;

@Controller
@RequestMapping("/report1")
public class ReportController {
    @Autowired
    ReportService reportService;
    @RequestMapping("/report")
    public String reportcomment( Integer dynamicId,String content,HttpSession httpSession){
        ReportVo reportVo = new ReportVo();
       //得到文章内容
        User user = (User) httpSession.getAttribute("user");
        Integer userId = user.getUserId();
        reportVo.setUserId(userId);
        Date date = new Date();
        reportVo.setCreateTime(date);
        reportVo.setDynamicId(dynamicId);
        reportVo.setReportContent(content);
        int i = reportService.addReport(reportVo);

return "forward:/dynamic/queryDynamic?DynamicId="+dynamicId;
    }
}
